home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
cmdity
/
yk212src.lha
/
Yak_2.12_Src
/
WBStartup
/
ARexx.c
next >
Wrap
C/C++ Source or Header
|
1995-10-18
|
2KB
|
97 lines
/*
*
* Send ARexx Command
*
*/
#include <exec/types.h>
#include <exec/libraries.h>
#include <exec/memory.h>
#include <rexx/rxslib.h>
#include <rexx/errors.h>
#include <proto/exec.h>
#include <proto/rexxsyslib.h>
#include <string.h>
#include "Arexx.h"
#include "Requesters.h"
#include "yak_locale_strings.h"
struct Library *RexxSysBase;
/*
* Send an ARexx command
* This function is slightly modified from Stefan Becker's one used in ToolManager
*/
LONG
SendARexxCommand(char *PortName, char *command)
{
LONG rc=RC_ERROR;
struct MsgPort *DummyPort;
/* Open ARexx system library */
if ((RexxSysBase = (struct Library *)OpenLibrary(RXSNAME,0)) &&
(DummyPort = CreateMsgPort ()))
{
struct RexxMsg *rxmsg;
if (rxmsg=CreateRexxMsg(DummyPort,NULL,NULL))
{
if (rxmsg->rm_Args[0]=CreateArgstring(command,strlen(command)))
{
struct MsgPort *AREXXPort; /* Port of ARexx resident process */
/* Init Rexx message */
rxmsg->rm_Action=RXCOMM|RXFF_NOIO;
/* Find port and send message */
Forbid();
if (PortName)
{
AREXXPort=FindPort(PortName);
}
else
{
AREXXPort=FindPort("AREXX");
}
if (AREXXPort)
{
PutMsg(AREXXPort,(struct Message *) rxmsg);
}
Permit();
/* Success? */
if (AREXXPort)
{
/* Yes, wait on reply and remove it */
WaitPort(DummyPort);
GetMsg(DummyPort);
/* Check return code */
rc=rxmsg->rm_Result1;
}
else
{
PostError(getString(AREXX_port_not_found_ERR), PortName);
}
ClearRexxMsg(rxmsg,1);
}
DeleteRexxMsg(rxmsg);
}
DeleteMsgPort(DummyPort);
CloseLibrary(RexxSysBase);
}
return(rc);
}